<?php
/**
*+------------------收藏控制器---------------------+
*--------------------------------------------------+
*+-------用户收藏（取消收藏)视频，比赛操作---------+
*+-------------------------------------------------+
*+-@author susy.liang <liangling@ilongyuan.com.cn>-+
*+-------------------------------------------------+
*/

namespace Home\Controller;

class FavourController extends BaseUserController {	

	/**
	*事件对象
	*/
	protected $eventObj = '';

	/**
	*参数初始化
	*@author susy.liang <liangling@ilongyuan.com.cn>
	*/
	protected function _initialize(){

		parent::_initialize();
		
		$this->eventObj = A('Api/Favour', 'Event');
	}
	/**
	*用户添加收藏
	*@author susy.liang <liangling@ilongyuan.com.cn>
	*/
	public function add(){

		$id = I('id', 0, 'intval');
		$res = $this->eventObj->add(UID, $id);

		if($res['code'] == 200)
			$this->ajaxReturn(array('state'=>0, 'info'=>'收藏成功'));
		else
			$this->ajaxReturn(array('state'=>-1, 'info'=>'收藏失败'));
	}


	/**
	*用户取消收藏
	*@author susy.liang <liangling@ilongyuan.com.cn>
	*/
	public function undo(){

		$id = I('id', 0, 'intval');
		$res = $this->eventObj->undo(UID, $id);

		if($res['code'] == 200)
			$this->ajaxReturn(array('state'=>0, 'info'=>'取消成功'));
		else
			$this->ajaxReturn(array('state'=>-1, 'info'=>'取消失败'));
	}

}
